package main

import (
	"code.game.com/proxy_server/server"
	"log"
	"os"
	"os/signal"
)


func main() {
	server.GetAPIInstance().Init()
	logfile, err := os.OpenFile("./proxy.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666);
	if err == nil {
		log.Println("write log to /opt/log/proxy.log",logfile);
		//log.SetOutput(logfile);
	} else {
		log.Println(err);
	}

	//if server.ParseConfig() != nil {
	//	log.Println("fail to ParseConfig, exit")
	//	return
	//}

	//go server.UpdateServerList()
	go server.StartTransfer();

	s := wait(os.Interrupt, os.Kill)
	log.Println("Got signal:", s)
}

func wait(signals ...os.Signal) os.Signal {
	c := make(chan os.Signal, 1)
	signal.Notify(c, signals...)
	s := <-c
	return s
}